capture cd "C:\Users/`c(username)'/Dropbox\WTO Cancer\data"
** gibler_randazzoAJPS
use GiblerRandazzoAJPS.dta , clear
drop _merge
sort ccode year
merge m:1 ccode using gattlist.dta 
drop if _m==2 
drop _merge
sort ccode year
merge m:1 ccode using wtolist.dta 
drop if _m==2 
drop _merge

gen gatt = year>=gattjoin
gen wto = year>=wtojoin
gen gattwto = gatt==1 | wto==1
gen study = ""
foreach n in orig noth fe time fet ct yfe cyfe {
gen method_`n' = ""
gen dv_`n' = ""
gen b_gatt_`n' = .
gen se_gatt_`n'= .
gen pval_gatt_`n' = .
gen lo_gatt_`n'=.
gen hi_gatt_`n'=.
gen N_gatt_`n'=.
}
gen studynum=.
gen timetrend=""
qui do gatt.do
local ii = 1
duplicates drop * , force
xtset ccode year
* model 1
logit negpolchg gattwto lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' orig
logit negpolchg gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' noth 
xtlogit negpolchg gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , fe
gatt `ii' fe
logit negpolchg gattwto lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' time
xtlogit negpolchg gattwto lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , fe
gatt `ii' fet
logit negpolchg gattwto lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.ccode#c.year if polityl>-5 , cl(ccode)
gatt `ii' ct
xtreg negpolchg gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.year if polityl>-5 , fe
gatt `ii' cyfe
clogit negpolchg gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , group(year)
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="age" if _n==`ii'
local ii=`ii'+1

* model 2
logit negpolchg gattwto oldj newj lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' orig
logit negpolchg gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' noth
xtlogit negpolchg gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , fe
gatt `ii' fe
logit negpolchg gattwto oldj newj lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' time
xtlogit negpolchg gattwto oldj newj lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , fe
gatt `ii' fet
logit negpolchg gattwto oldj newj lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.ccode#c.year if polityl>-5 , cl(ccode)
gatt `ii' ct
xtreg negpolchg gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.year if polityl>-5 , fe
gatt `ii' cyfe
clogit negpolchg gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , group(year)
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="age" if _n==`ii'
local ii=`ii'+1

* model 3
logit neg4polchange gattwto lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' orig
logit neg4polchange gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' noth
xtlogit neg4polchange gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , fe
gatt `ii' fe
logit neg4polchange gattwto lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' time
xtlogit neg4polchange gattwto lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , fe
gatt `ii' fet
logit neg4polchange gattwto lngdpl /*age_democl*/  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.ccode#c.year if polityl>-5 & e(sample), cl(ccode)
gatt `ii' ct
xtreg neg4polchange gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.year if polityl>-5 , fe
gatt `ii' cyfe
clogit neg4polchange gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , group(year)
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="age" if _n==`ii'
local ii=`ii'+1

* model 4
logit neg4polchange gattwto oldj newj lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' orig
logit neg4polchange gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' noth
xtlogit neg4polchange gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , fe
gatt `ii' fe
logit neg4polchange gattwto oldj newj lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5
gatt `ii' time
xtlogit neg4polchange gattwto oldj newj lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , fe
gatt `ii' fet
logit neg4polchange gattwto oldj newj lngdpl /*age_democl*/  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.ccode#c.year if polityl>-5 & e(sample), cl(ccode)
gatt `ii' ct
xtreg neg4polchange gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.year if polityl>-5 , fe
gatt `ii' cyfe
clogit neg4polchange gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>-5 , group(year)
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="age" if _n==`ii'
local ii=`ii'+1


* model 5
logit negpolchg gattwto lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2 , cl(ccode)
gatt `ii' orig
logit negpolchg gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2, cl(ccode)
gatt `ii' noth
xtlogit negpolchg gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2, fe
gatt `ii' fe
logit negpolchg gattwto lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2, cl(ccode)
gatt `ii' time
xtlogit negpolchg gattwto lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2, fe
gatt `ii' fet
logit negpolchg gattwto lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.ccode#c.year if e(sample) & ccode~=369 & polityl>2, cl(ccode)
* Does not converge with country dummies -- need to drop 369
gatt `ii' ct
xtreg negpolchg gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.year if polityl>2, fe
gatt `ii' cyfe
clogit negpolchg gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl  if polityl>2, group(year)
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="age" if _n==`ii'
local ii=`ii'+1

* model 6
logit negpolchg gattwto oldj newj lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2 , cl(ccode)
gatt `ii' orig
logit negpolchg gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2, cl(ccode)
gatt `ii' noth
xtlogit negpolchg gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2, fe
gatt `ii' fe
logit negpolchg gattwto oldj newj lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2, cl(ccode)
gatt `ii' time
xtlogit negpolchg gattwto oldj newj lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2, fe
gatt `ii' fet
logit negpolchg gattwto oldj newj lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.ccode#c.year if e(sample) & ccode~=369 & polityl>2, cl(ccode)
* Does not converge with country dummies -- need to drop 369
gatt `ii' ct
xtreg negpolchg gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.year if polityl>2, fe
gatt `ii' cyfe
clogit negpolchg gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl  if polityl>2, group(year)
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="age" if _n==`ii'
local ii=`ii'+1


* model 7
logit neg4polchange gattwto lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2
gatt `ii' orig
logit neg4polchange gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2
gatt `ii' noth
xtlogit neg4polchange gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2 , fe
gatt `ii' fe
logit neg4polchange gattwto lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2
gatt `ii' time
xtlogit neg4polchange gattwto lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2 , fe
gatt `ii' fet
logit neg4polchange gattwto lngdpl /*age_democl*/  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.ccode#c.year if polityl>2 & e(sample), cl(ccode)
gatt `ii' ct
xtreg neg4polchange gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.year if polityl>2 , fe
gatt `ii' cyfe
clogit neg4polchange gattwto lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2 , group(year)
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="age" if _n==`ii'
local ii=`ii'+1

* model 8
logit neg4polchange gattwto oldj newj lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2
gatt `ii' orig
logit neg4polchange gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2
gatt `ii' noth
xtlogit neg4polchange gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2 , fe
gatt `ii' fe
logit neg4polchange gattwto oldj newj lngdpl age_democl hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2
gatt `ii' time
xtlogit neg4polchange gattwto oldj newj lngdpl age_democl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2 , fe
gatt `ii' fet
logit neg4polchange gattwto oldj newj lngdpl /*age_democl*/  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.ccode#c.year if polityl>2 & e(sample), cl(ccode)
gatt `ii' ct
xtreg neg4polchange gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl i.year if polityl>2 , fe
gatt `ii' cyfe
clogit neg4polchange gattwto oldj newj lngdpl  hist_revert_polityl econ_crisis_3percentl terr_rivl militarize_neighborl if polityl>2 , group(year)
gatt `ii' yfe
replace studynum = `ii' if _n==`ii'   
replace timetrend="age" if _n==`ii'
local ii=`ii'+1

replace study = "Gibler Randazzo" if studynum~=. 	

keep study-timetrend
drop if studynum==.
compress
save giblerrandazzo.dta , replace
